package com.xyh.transaction.common;

import java.util.HashMap;
import java.util.Map;

public enum OrderDeliveryType {
    OFFLINE_PICKUP("线下自提"),
    EXPRESS_DELIVERY("快递配送");

    private static final Map<String, OrderDeliveryType> map = new HashMap<>();

    static {
        for (OrderDeliveryType type : OrderDeliveryType.values()) {
            map.put(type.getDetail(), type);
        }
    }

    private final String detail;

    OrderDeliveryType(String detail) {
        this.detail = detail;
    }

    public String getDetail() {
        return detail;
    }

    public static OrderDeliveryType getByDetail(String detail) {
        OrderDeliveryType deliveryType = map.get(detail);
        if (deliveryType == null) {
            // 处理未知的详情字符串，例如返回一个默认值或抛出异常
            throw new IllegalArgumentException("Unknown delivery type: " + detail);
        }
        return deliveryType;
    }
}
